import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

import { getPopupContainer } from '@vben/utils';

import { Tag } from 'ant-design-vue';
import { h } from 'vue';

/**
 * authScopeOptions user也会用到
 */
export const authScopeOptions = [
  { color: 'green', label: '全部数据权限', value: '1' },
  { color: 'default', label: '自定数据权限', value: '2' },
  { color: 'orange', label: '本部门数据权限', value: '3' },
  { color: 'cyan', label: '本部门及以下数据权限', value: '4' },
  { color: 'error', label: '仅本人数据权限', value: '5' },
  { color: 'default', label: '部门及以下或本人数据权限', value: '6' },
];

export const querySchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'filter',
    label: '角色名称',
    componentProps: {
      placeholder: '请输入角色名称',
    },
  },
];

export const columns: VxeGridProps['columns'] = [
  { type: 'checkbox', width: 60 },
  {
    title: '角色名称',
    field: 'name',
  },
  {
    title: '默认角色',
    field: 'isDefault',
    slots: {
      default: ({ row }) => {
        return h(Tag, { color: row.isDefault ? 'green' : 'red' }, () => row.isDefault ? '是' : '否');
      }
    }
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    resizable: false,
    width: '200',
  },
];
export const formSchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
    fieldName: 'id',
    label: '角色ID',
  },
  {
    component: 'Input',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
    fieldName: 'concurrencyStamp',
    label: '并发标记',
  },
  {
    component: 'Input',
    fieldName: 'name',
    label: '角色名称',
    rules: 'required',
    componentProps: {
      placeholder: '请输入角色名称',
    },
  },
  {
    component: 'RadioGroup',
    fieldName: 'isDefault',
    label: '默认角色',
    rules: 'required',
    defaultValue: false,
    //help: '新用户注册时是否自动分配此角色',
    componentProps: {
      options: [
        { label: '是', value: true },
        { label: '否', value: false }
      ]
    }
  },
];
